(function() {
    angular.module('BlurAdmin.pages.Administration')
        .controller('AdministrationMCtrl', AdministrationMCtrl);

    function AdministrationMCtrl($scope, $datepicker, $openModal) {
        //弹窗框
        $scope.open = $openModal; //创建实例化对象
        function fn(val) { //关闭模态框方法
            $scope.myopen.opt_close = val;
        }
        $scope.myopen = function(page, size) { //打开模态框
            $scope.open.newOpen(page, size, $scope, fn, 'static');
        }
        $scope.myopen2 = function(page, size) { //打开模态框 ,可关闭
            $scope.open.newOpen(page, size, $scope, fn);
        }


        //打开饼状图
        $scope.ope_pie = function(val, text) {
            console.log(val);
            $scope.popimg = val;
            $scope.popimg_text = text;
            $scope.open.newOpen('app/pages/AdministrationM/pie.html', 'md', $scope);
        }


        //日期插件
        $scope.format = "yyyy/MM/dd";
        $scope.altInputFormats = ['yyyy-MM-dd-HH'];
        $scope.dat = {
            dat1: $datepicker.dataNew(),
            dat2: $datepicker.dataNew(),
            dat3: $datepicker.dataNew(),
            dat4: $datepicker.dataNew(),
        };

        //分页
        $scope.items_page = 5; //每页多少条
        $scope.maxSize = 5; //底下显示几个页
        $scope.bigTotalItems = 50; //一共多少数据
        $scope.bigCurrentPage = 1; //当前是第几页

        $scope.pageChanged = function() { //选择页面方法
            setTimeout(function() {
                var Page_num = $('#systemTable_Page_num').text(); //选中的页面数
                //  Page_num = parseInt(Page_num);
                //  skip = (Page_num - 1) * 10;
                console.log(Page_num);
            }, 20);
        };
        $scope.is_data = '';
        //类别数据

        $scope.informationData = [{
                num: 1,
                browser: "张三的鼻光宝",
                text: "12分钟",
                qiangdu: '100',
                name: '鼻光宝',
                addaers: '102993940823908432',
                start_data: '2011/02/02',
                end_data: '2016/06/18',
                user: '张三',
                pageload: {
                    name: '种类',
                    datapoints: [
                        { x: '调血气', y: 46 },
                        { x: '鼻炎', y: 999 },
                        { x: '净血', y: 12 },
                        { x: '通筋络', y: 12 }
                    ]
                }
            },
            {
                num: 1,
                browser: "张三的鼻光宝",
                text: "33分钟",
                qiangdu: '100',
                name: '鼻光宝',
                addaers: '102993940823908432',
                start_data: '2011/02/02',
                end_data: '2016/06/18',
                user: '张三',
            },
            {
                num: 1,
                browser: "张三的鼻光宝",
                text: "32分钟",
                qiangdu: '100',
                name: '鼻光宝',
                addaers: '102993940823908432',
                start_data: '2011/02/02',
                end_data: '2016/06/18',
                user: '张三',
            },
            {
                num: 1,
                browser: "张三的鼻光宝",
                text: "332分钟",
                qiangdu: '100',
                name: '鼻光宝',
                addaers: '102993940823908432',
                start_data: '2011/02/02',
                end_data: '2016/06/18',
                user: '张三',
            },
            {
                num: 1,
                browser: "张三的鼻光宝",
                text: "66分钟",
                qiangdu: '100',
                name: '鼻光宝',
                addaers: '102993940823908432',
                start_data: '2011/02/02',
                end_data: '2016/06/18',
                user: '张三',
            },
            {
                num: 1,
                browser: "张三的鼻光宝",
                text: "96分钟",
                qiangdu: '100',
                name: '鼻光宝',
                addaers: '102993940823908432',
                start_data: '2011/02/02',
                end_data: '2016/06/18',
                user: '张三',
                pageload: {
                    name: '种类',
                    datapoints: [
                        { x: '调血气', y: 100 },
                        { x: '鼻炎', y: 100 },
                        { x: '净血', y: 100 },
                        { x: '通筋络', y: 100 }
                    ]
                }
            }




        ];

        //饼状图数据
        $scope.myname = '';
        $scope.tpo = 1;
        $scope.myTabs = function(val) {
            $scope.tpo = val;
        }
        var pageload = {
            name: '种类',
            datapoints: [
                { x: '调血气', y: 200 },
                { x: '鼻炎', y: 100 },
                { x: '净血', y: 45 },
                { x: '通筋络', y: 130 }
            ]
        };


        $scope.jbg_config = {
            title: {
                text: $scope.myname,
                subtext: '看好不好用',
                x: 'center'
            },
            tooltip: {
                trigger: 'item',
                formatter: "{b} : {c} 分钟"
            },
            legend: { //点击类别显示
                show: true,
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} 分钟"
                },
                orient: 'vertical',
                y: 'center',
                x: '220px',
                padding: '20',
                data: ['调血气', "鼻炎", "净血", "通筋络"]
            },
            series: [{
                itemStyle: {
                    normal: {
                        label: {
                            position: 'inner',
                            formatter: function(a, b, c, d) {
                                return (d - 0).toFixed(0) + '%';
                            }
                        },
                        labelLine: { show: false }
                    },
                    emphasis: {
                        label: {
                            show: true,
                            formatter: '22%'
                        }
                    }
                },

                name: '访问来源',
                type: 'pie',
                radius: '55%',
                center: ['60%', '55%'],
                data: [
                    // { name: "调血气", value: 100 },
                    // { name: "鼻炎", value: 100 },
                    // { name: "净血", value: 100 },
                    // { name: "通筋络", value: 100 }
                ]
            }]
        };
        $scope.data = [pageload];


    }

})();